home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.xa.undo;
-
- import com.extensibility.app.BaseUndoable;
- import com.extensibility.app.DialogFactory;
- import com.extensibility.app.UI;
- import com.extensibility.xa.AggregateAttributeDecl;
- import com.extensibility.xa.DeclTable;
- import com.extensibility.xa.SchemaWin;
- import com.extensibility.xml.BaseDeclaration;
- import com.extensibility.xml.InternalPEDeclaration;
- import java.util.Enumeration;
- import javax.swing.ListSelectionModel;
-
- public class DeclTableClrActionUndoable extends ClearDeclsUndoable {
- DeclTable tableToUndo;
- int row;
- int orgCol;
-
- public DeclTableClrActionUndoable(DeclTable var1, SchemaWin var2) {
- super(var2);
- this.tableToUndo = var1;
- }
-
- public boolean doClear() {
- boolean var1 = false;
- this.orgCol = this.tableToUndo.getSelectedColumn();
- if (!this.tableToUndo.stopEditing()) {
- return var1;
- } else {
- ListSelectionModel var2 = this.tableToUndo.getSelectionModel();
- this.row = this.tableToUndo.getSelectedRow();
-
- for(int var3 = var2.getMinSelectionIndex(); var3 <= var2.getMaxSelectionIndex(); ++var3) {
- if (var2.isSelectedIndex(var3)) {
- BaseDeclaration var4 = this.tableToUndo.getDeclTableModel().getDeclaration(var3);
- if (var4 != null) {
- if (!((ClearDeclsUndoable)this).getSchemaDoc().isEditable(var4)) {
- DialogFactory.showException(((BaseUndoable)this).getWindow(), 106, UI.getString("error.decl.not.editable"), var4.getName());
- } else {
- if (var4 instanceof InternalPEDeclaration) {
- Enumeration var5 = ((ClearDeclsUndoable)this).getSchemaDoc().getUsedBy((InternalPEDeclaration)var4);
- if (var5.hasMoreElements()) {
- String var6 = UI.getString("stop.delete.in.use", var4.getName(), ((BaseDeclaration)var5.nextElement()).getName());
- DialogFactory.stop(((BaseUndoable)this).getWindow(), var6);
- continue;
- }
- }
-
- if (!var1) {
- var1 = true;
- }
-
- super.toRemove.addToSet(var4);
- }
- }
- }
- }
-
- if (var1) {
- ((ClearDeclsUndoable)this).doCommand();
- }
-
- if (this.row < this.tableToUndo.getRowCount()) {
- this.tableToUndo.select(this.row, this.orgCol);
- } else if (this.row > 0) {
- this.tableToUndo.select(this.row - super.toRemove.size(), this.orgCol);
- }
-
- return var1;
- }
- }
-
- public void undo() {
- super.undo();
- if (super.toRemove.size() > 0) {
- Object var1 = (BaseDeclaration)super.toRemove.elementAt(0);
- if (var1 != null && var1 instanceof AggregateAttributeDecl) {
- var1 = ((AggregateAttributeDecl)var1).getFirst();
- }
-
- if (var1 != null) {
- this.tableToUndo.select((BaseDeclaration)var1);
- }
- }
-
- }
-
- public void redo() {
- super.redo();
- ((ClearDeclsUndoable)this).doCommand();
- if (this.row < this.tableToUndo.getRowCount()) {
- this.tableToUndo.select(this.row, this.orgCol);
- } else if (this.row > 0) {
- this.tableToUndo.select(this.row - super.toRemove.size(), this.orgCol);
- }
-
- }
- }
-